<script setup>
import { onMounted, ref } from 'vue'
import { RouterView } from 'vue-router'
import router from '@/router'
import { Icon } from '@iconify/vue'

const activeMenu = ref('/local')
const handleOpen = (key, keyPath) => {
  // console.log(key, keyPath)
}
const handleClose = (key, keyPath) => {
  // console.log(key, keyPath)
}
const handleSelect = (key, keyPath) => {}
onMounted(() => {
  activeMenu.value = router.currentRoute.value.path
})
</script>
<template>
  <el-container class="common-layout h-100">
    <el-aside width="200px" class="h-100">
      <el-menu
        :default-active="activeMenu"
        class="h-100"
        router
        @open="handleOpen"
        @close="handleClose"
        @select="handleSelect"
        background-color="#343434"
        text-color="#fff"
        active-text-color="#ffd04b"
      >
        <el-menu-item index="/local">
          <el-icon><Monitor /></el-icon>
          <span>本地</span>
        </el-menu-item>
        <el-sub-menu index="1">
          <template #title>
            <el-icon><setting /></el-icon>
            <span>系统</span>
          </template>
          <el-menu-item index="1-1">item one</el-menu-item>
          <el-menu-item index="1-2">item two</el-menu-item>
          <el-menu-item index="1-3">item three</el-menu-item>
          <el-sub-menu index="1-4">
            <template #title>item four</template>
            <el-menu-item index="1-4-1">item one</el-menu-item>
          </el-sub-menu>
        </el-sub-menu>
        <el-sub-menu index="2">
          <template #title>
            <el-icon><Camera /></el-icon>
            <span>抓拍</span>
          </template>
          <el-menu-item index="1-1">应用模式</el-menu-item>
          <el-menu-item index="1-2">抓拍参数</el-menu-item>
          <el-menu-item index="1-3">抓拍图像</el-menu-item>
          <el-menu-item index="1-4-1">高级</el-menu-item>
        </el-sub-menu>

        <el-sub-menu index="4">
          <template #title>
            <icon
              icon="tdesign:internet"
              :size="26"
              class="m-r-10px text-20px color-666"
              style="margin-left: 3px"
            ></icon>
            <span>网络</span>
          </template>
          <el-menu-item index="1-1">应用模式</el-menu-item>
        </el-sub-menu>
      </el-menu>
    </el-aside>
    <Transition appear enter-active-class="animate__animated animate__bounceInRight">
      <el-main>
        <RouterView />
      </el-main>
    </Transition>
  </el-container>
</template>